package com.milkcoffee.jvm.lesson01;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author zxs
 */
public class CustomizeClassloaderTest {

    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {

        //Users/milkcoffee/gitee/study/jvm/target/classes/com/milkcoffee/jvm/lesson01/User.class
        CustomizeClassloader classloader = new CustomizeClassloader("/Users/milkcoffee/Downloads");
        Class<?> clazz = classloader.loadClass("com.milkcoffee.jvm.lesson01.User");

        Object obj = clazz.newInstance();
        Method method = clazz.getDeclaredMethod("test", null);
        method.invoke(obj, null);
        System.out.println(clazz.getClassLoader().getClass().getName());
    }
}
